package day1;

import org.junit.Test;

import java.util.Scanner;

public class HomeWork {

    @Test
    public void tes1() {
        // 构造了一个Scanner对象，这个对象可以帮你完成从控制台读取内容
        Scanner scanner = new Scanner(System.in);
        // int year = 2200;
        System.out.println("请输入年份：");
        int year = scanner.nextInt();
        if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) {
            // 豆豆加加
            // System.out.println("您输入的2000年是闰年");
            System.out.println("您输入的" + year + "年是闰年");
        } else {
            System.out.println("不是闰年");
        }
    }

    @Test
    public void test2() {
        int num1 = 3;
        int num2 = 5;
        int temp = num1;
        num1 = num2;
        num2 = temp;
        System.out.println("num1: " + num1);
        System.out.println("num2: " + num2);
    }

    @Test
    public void test3() {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入单价：");
        double unitPrice = scanner.nextDouble();
        System.out.println("请输入数量：");
        double count = scanner.nextDouble();
        System.out.println("请输入金额：");
        double price = scanner.nextDouble();
        double totalPrice = unitPrice * count;
        if (totalPrice > 500) {
            // totalPrice = totalPrice * 0.8;
            totalPrice *= 0.8;
        }
        double returnPrice = price - totalPrice;
        if (returnPrice >= 0) {
            System.out.println("应收" + totalPrice + "钱，找零" + returnPrice + "钱");
        } else {
            System.out.println("顾客付的钱不够");
        }

    }

}
